/**
 * Created by HUANG on 2016/1/21.
 */
'use strict';
angular.module('nec-admin.admin')
    .controller('adminController', ['$scope', '$state', 'adminService','sweetAlert','toast',
        function ($scope, $state ,adminService,sweetAlert,toast) {
            adminService.searchInfo().then(function(resp){
                $scope.classes=resp.data;
                $scope.class = $scope.classes[0];
            },function(){
                toast.error('获取班级信息失败');
            });

            adminService.itemList().then(function(resp){
                $scope.courses = resp.data;
                $scope.course = $scope.courses[0];
            },function(){
                toast.error('获取科目信息失败');
            });

            $scope.submit = function(){
                adminService.submitItem($scope.class.classId,$scope.course.sbjId).then(function(){
                    toast.success('添加成功');
                    $state.go('admin.list');
                },function(){
                    toast.error('添加失败');
                });
            }
        }]);
